import {
  Toast
} from "vant";
import cTitle from "components/title";
import { scrollMixin } from "../../../utils/mixin";
export default {
  mixins: [scrollMixin], //加载更多
  data() {
    return {
      textArr: [], //总数组
      uid: '',
      page: 1,
      total: 0,
      isLoadMore: true
    };
  },

  components: {
    cTitle
  },
  activated() {
    console.log(this.$route.params, '聊天记录');
    this.uid = this.$route.params.id ? this.$route.params.id : '';
    this.getData();
  },
  computed: {

  },
  methods: {
    getData() {
      $http.get("ZhengChengYc.chakanliaotianlog", {
        uid: this.uid,
        page: this.page
      }, "加载中").then((res) => {
        if (res.result == 1) {
          console.log(res, 'chakanliaotianlog')
          this.total = res.data.last_page
          let dataList = this.textArr
          if (this.page == 1) {
            dataList = res.data.data;
          } else {
            dataList = dataList.concat(res.data.data)
          }
          
          this.textArr = dataList;
          this.isLoadMore = true;
          
        }
      });
    },
    //获取更多数据
    getMoreData() {
      console.log("伙伴详情", this.isLoadMore);
      if (!this.isLoadMore) return;
      this.isLoadMore = false; // 防止多次请求分页数据
      if (this.page >= this.total) {
          Toast('到底了')
        return;
      } else {
        this.page += 1;
        this.getData();
      }
    },

  }
};